home *** CD-ROM | disk | FTP | other *** search
Text File | 2003-07-17 | 30.5 KB | 1,002 lines |
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Mar 14, 1997
- //
- // Description:
- // This script is defines the option box for the rebuild surface menu item.
- //
-
-
- //
- // Procedure Name:
- // setOptionVars
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // Whether to set the options to default values.
- //
- // Return Value:
- // None.
- //
- proc setOptionVars(int $forceFactorySettings)
- {
- rebuildSurfaceSetOptionVars( $forceFactorySettings );
- }
-
- //
- // Procedure Name:
- // rebuildSurfaceVisibility
- //
- // Description:
- // Depending on the options, some other options do or do not show.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- // Return Value:
- // None.
- //
-
- proc int getRebuildType()
- // Description:
- // Return the "1" based rebuild type.
- {
- int $rebType = `radioButtonGrp -q -select rebuildTypeRadioGroup1`;
- if( 0 == $rebType ) {
- $rebType = `radioButtonGrp -q -sl rebuildTypeRadioGroup2`;
- if( 0 == $rebType ) {
- $rebType = `radioButtonGrp -q -sl rebuildTypeRadioGroup3`;
- if( 0 == $rebType ) {
- if( 1 == `radioButtonGrp -q -nrb rebuildTypeRadioGroup4` ){
- $rebType = 2;
- }
- else {
- $rebType = `radioButtonGrp -q -sl rebuildTypeRadioGroup4`;
- }
-
- $rebType += 2;
- }
- $rebType += 2;
- }
- $rebType += 2;
- }
-
- return $rebType;
- }
-
- global proc rebuildSurfaceVisibility( string $parent,
- int $useGlobalTol,
- int $rebuildType,
- int $keepCVs,
- int $keepNumSpans )
- {
- if( $useGlobalTol < 0 ) {
- $useGlobalTol = `radioButtonGrp -q -select toleranceRadioButtonGrp`;
- }
- if( $rebuildType < 0 ) {
- $rebuildType = getRebuildType();
- }
- if( $keepCVs < 0 ) {
- $keepCVs = `checkBoxGrp -q -v2 keepCheckBoxGrp`;
- }
- if( $keepNumSpans < 0 ) {
- $keepNumSpans = `checkBoxGrp -q -v3 keepCheckBoxGrp`;
- }
- // can only show slider of not keeping CVs or numSpans
- int $showCVslider = ((!$keepCVs) && (!$keepNumSpans));
-
- switch( $rebuildType ) {
- case 1:
- default:
- // Uniform (0 for the attribute)
- intSliderGrp -e -en ($showCVslider) numSpansUIntSliderGrp;
- intSliderGrp -e -en ($showCVslider) numSpansVIntSliderGrp;
- checkBoxGrp -e -en true keepCheckBoxGrp;
- checkBoxGrp -e -en1 (!$keepCVs) -en2 true -en3 (!$keepCVs) keepCheckBoxGrp;
- radioButtonGrp -e -en true directionRadioButtonGrp;
-
- frameLayout -e -collapse false uniformTypeLayout;
- frameLayout -e -collapse true toleranceLayout;
- frameLayout -e -collapse true endKnotsLayout;
- break;
-
- case 2:
- // Reduce (1 for the attribute)
- checkBoxGrp -e -en false keepCheckBoxGrp;
-
- frameLayout -e -collapse true uniformTypeLayout;
- frameLayout -e -collapse false toleranceLayout;
- radioButtonGrp -e -en true directionRadioButtonGrp;
- if( $useGlobalTol == 1 ) {
- tabLayout -e -selectTab globalToleranceNoSlider
- localToleranceTabLayout;
- }
- else {
- tabLayout -e -selectTab localToleranceSlider
- localToleranceTabLayout;
- }
- frameLayout -e -collapse true endKnotsLayout;
- break;
-
- case 3:
- // Match (2 for the attribute)
- checkBoxGrp -e -en true keepCheckBoxGrp;
- // keep numspans must be disabled for match knots
- checkBoxGrp -e -en1 true -en2 true -en3 false keepCheckBoxGrp;
-
- radioButtonGrp -e -en true directionRadioButtonGrp;
-
- frameLayout -e -collapse true uniformTypeLayout;
- frameLayout -e -collapse true toleranceLayout;
- frameLayout -e -collapse true endKnotsLayout;
- break;
-
- case 4:
- // Remove multiple (3 for the attribute)
- checkBoxGrp -e -en false keepCheckBoxGrp;
- // no direction option for nonrational - always does both
- radioButtonGrp -e -en false directionRadioButtonGrp;
-
- frameLayout -e -collapse true uniformTypeLayout;
- frameLayout -e -collapse true toleranceLayout;
- frameLayout -e -collapse true endKnotsLayout;
- break;
-
- case 5:
- // force non-rational (4 for the attribute)
- checkBoxGrp -e -en false keepCheckBoxGrp;
-
- // no direction option for no mult - always does both
- radioButtonGrp -e -en false directionRadioButtonGrp;
-
- frameLayout -e -collapse true uniformTypeLayout;
- frameLayout -e -collapse false toleranceLayout;
- if( $useGlobalTol == 1 ) {
- tabLayout -e -selectTab globalToleranceNoSlider
- localToleranceTabLayout;
- }
- else {
- tabLayout -e -selectTab localToleranceSlider
- localToleranceTabLayout;
- }
- frameLayout -e -collapse true endKnotsLayout;
- break;
-
- case 6:
- // rebuild ends (5 for the attribute)
- checkBoxGrp -e -en false keepCheckBoxGrp;
- radioButtonGrp -e -en true directionRadioButtonGrp;
-
- frameLayout -e -collapse true uniformTypeLayout;
- frameLayout -e -collapse true toleranceLayout;
- frameLayout -e -collapse false endKnotsLayout;
- break;
-
- case 7:
- // trim convert (6 for the attribute)
- intSliderGrp -e -en true numSpansUIntSliderGrp;
- intSliderGrp -e -en true numSpansVIntSliderGrp;
- checkBoxGrp -e -en true keepCheckBoxGrp;
- checkBoxGrp -e -en1 false -en2 false -en3 true keepCheckBoxGrp;
- radioButtonGrp -e -en false directionRadioButtonGrp;
-
- frameLayout -e -collapse false uniformTypeLayout;
- frameLayout -e -collapse true toleranceLayout;
- frameLayout -e -collapse true endKnotsLayout;
- break;
-
- case 8:
- // bezier (7 for the attribute)
- intSliderGrp -e -en ($showCVslider) numSpansUIntSliderGrp;
- intSliderGrp -e -en ($showCVslider) numSpansVIntSliderGrp;
- checkBoxGrp -e -en true keepCheckBoxGrp;
- checkBoxGrp -e -en1 false -en2 false -en3 true keepCheckBoxGrp;
- radioButtonGrp -e -en false directionRadioButtonGrp;
-
- frameLayout -e -collapse false uniformTypeLayout;
- frameLayout -e -collapse true toleranceLayout;
- frameLayout -e -collapse true endKnotsLayout;
- break;
-
- }
- }
-
- //
- // Procedure Name:
- // rebuildSurfaceSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
-
- global proc rebuildSurfaceSetup( string $parent,
- int $forceFactorySettings,
- string $goToTool )
- {
- // Retrieve the option settings
- //
- setOptionVars($forceFactorySettings);
- rebuildSurfaceToolSetup( $forceFactorySettings, $goToTool );
-
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls.
-
- // Query the optionVar's and set the values into the controls
- //
- int $rebuildType = `optionVar -q rebuildSurfaceType` + 1;
- int $numSpansU = `optionVar -q rebuildSurfaceTypeUniformNumSpansU`;
- int $numSpansV = `optionVar -q rebuildSurfaceTypeUniformNumSpansV`;
- int $degreeU = `optionVar -q rebuildSurfaceTypeUniformDegreeU`;
- int $degreeV = `optionVar -q rebuildSurfaceTypeUniformDegreeV`;
- int $keepRange = `optionVar -q rebuildSurfaceKeepRange`;
- int $direction = `optionVar -q rebuildSurfaceDirection`;
- int $endKnots = `optionVar -q rebuildSurfaceEndKnots`;
- int $keepControlPoints = `optionVar -q rebuildSurfaceKeepControlPoints`;
- int $keepCornerPts = `optionVar -q rebuildSurfaceKeepCornerPoints`;
- int $keepNumSpans = `optionVar -q rebuildSurfaceKeepNumSpans`;
- int $useGlobalTol = `optionVar -q rebuildSurfaceUseGlobalTolerance`;
- radioButtonGrp -e -select (2 - $useGlobalTol) toleranceRadioButtonGrp;
-
- float $localTol = `optionVar -q rebuildSurfaceLocalTolerance`;
- int $keepOriginal = `optionVar -q rebuildSurfaceKeepOriginal`;
- int $polys = `optionVar -q rebuildSurfacePolys`;
-
- // Set the controls
- //
- if( (1 == $rebuildType) || (2 == $rebuildType) ) {
- radioButtonGrp -e -select $rebuildType rebuildTypeRadioGroup1;
- }
- else if( $rebuildType == 3 || $rebuildType == 4 ) {
- int $temp = $rebuildType - 2;
- radioButtonGrp -e -select $temp rebuildTypeRadioGroup2;
- }
- else if( $rebuildType == 5 || $rebuildType == 6 ) {
- int $temp = $rebuildType - 4;
- radioButtonGrp -e -select $temp rebuildTypeRadioGroup3;
- }
- else {
- int $temp = $rebuildType - 6;
- if( 1 == `radioButtonGrp -q -nrb rebuildTypeRadioGroup4` ) {
- $temp = 1;
- optionVar -iv rebuildSurfaceType 7;
- }
- radioButtonGrp -e -select $temp rebuildTypeRadioGroup4;
- }
- intSliderGrp -e -value $numSpansU numSpansUIntSliderGrp;
- intSliderGrp -e -value $numSpansV numSpansVIntSliderGrp;
-
- switch($degreeU) {
- case 1: radioButtonGrp -e -select 1 rebuildSrfUDegree123; break;
- case 2: radioButtonGrp -e -select 2 rebuildSrfUDegree123; break;
- case 3: radioButtonGrp -e -select 3 rebuildSrfUDegree123; break;
- case 5: radioButtonGrp -e -select 1 rebuildSrfUDegree57; break;
- case 7: radioButtonGrp -e -select 2 rebuildSrfUDegree57; break;
- case 0: radioButtonGrp -e -select 3 rebuildSrfUDegree57; break;
- default: radioButtonGrp -e -select 3 rebuildSrfUDegree123; break;
- }
- switch($degreeV) {
- case 1: radioButtonGrp -e -select 1 rebuildSrfVDegree123; break;
- case 2: radioButtonGrp -e -select 2 rebuildSrfVDegree123; break;
- case 3: radioButtonGrp -e -select 3 rebuildSrfVDegree123; break;
- case 5: radioButtonGrp -e -select 1 rebuildSrfVDegree57; break;
- case 7: radioButtonGrp -e -select 2 rebuildSrfVDegree57; break;
- case 0: radioButtonGrp -e -select 3 rebuildSrfVDegree57; break;
- default: radioButtonGrp -e -select 3 rebuildSrfVDegree123; break;
- }
-
- radioButtonGrp -e -select ($endKnots+1) endKnotsRadioButtonGrp;
- radioButtonGrp -e -select ($keepRange+1) keepRangeRadioButtonGrp;
- radioButtonGrp -e -select ($direction+1) directionRadioButtonGrp;
- checkBoxGrp -e -value1 $keepCornerPts keepCheckBoxGrp;
- checkBoxGrp -e -value2 $keepControlPoints keepCheckBoxGrp;
- checkBoxGrp -e -value3 $keepNumSpans keepCheckBoxGrp;
- radioButtonGrp -e -select $useGlobalTol toleranceRadioButtonGrp;
- floatSliderGrp -e -value $localTol localTolFloatFieldGrp;
- checkBoxGrp -e -value1 $keepOriginal keepOriginalCheckBox;
-
- // No "Bezier" option on the geometry output, as you just
- // want the NURBS that is rebuilt as Bezier.
- if( 3 == $polys ) $polys = 0;
- radioButtonGrp -edit -select ($polys+1) outputPolyRadioButtonGrp;
-
- // Nurbs or poly ?
- //
- switch( $polys ) {
- case 0:
- default:
- frameLayout -e -cl false geomOptionLN;
- frameLayout -e -cl true geomOptionLP;
- frameLayout -e -cl true geomOptionLS;
- break;
- case 1:
- frameLayout -e -cl true geomOptionLN;
- frameLayout -e -cl false geomOptionLP;
- frameLayout -e -cl true geomOptionLS;
- break;
- case 2:
- frameLayout -e -cl true geomOptionLN;
- frameLayout -e -cl true geomOptionLP;
- frameLayout -e -cl false geomOptionLS;
- break;
- }
-
- nurbsToPolySetup( $parent, $forceFactorySettings );
- nurbsToSubdivSetup( $parent, $forceFactorySettings );
-
- rebuildSurfaceVisibility $parent $useGlobalTol
- $rebuildType $keepControlPoints $keepNumSpans;
-
- if( "" != $goToTool ) {
- checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
- scriptToolExtraWidget;
- checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
- scriptToolExtraWidget;
- }
- }
-
- //
- // Procedure Name:
- // rebuildSurfaceCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
-
- global proc rebuildSurfaceCallback( string $parent,
- int $doIt,
- string $goToTool )
- {
- setParent $parent;
-
- // Set the optionVar's from the current control values, and then perform
- // the command
- //
- int $rebuildType = getRebuildType();
-
- int $numSpansU = `intSliderGrp -q -value numSpansUIntSliderGrp`;
- int $numSpansV = `intSliderGrp -q -value numSpansVIntSliderGrp`;
-
- int $degreeBtn123 = `radioButtonGrp -q -select rebuildSrfUDegree123`;
- int $degreeBtn57 = `radioButtonGrp -q -select rebuildSrfUDegree57`;
- int $degreeU;
- switch($degreeBtn123) {
- case 1: $degreeU = 1; break;
- case 2: $degreeU = 2; break;
- case 3: $degreeU = 3; break;
- default:
- switch($degreeBtn57) {
- case 1: $degreeU = 5; break;
- case 2: $degreeU = 7; break;
- case 3: $degreeU = 0; break;
- default: $degreeU = 3; break;
- }
- break;
- }
-
- $degreeBtn123 = `radioButtonGrp -q -select rebuildSrfVDegree123`;
- $degreeBtn57 = `radioButtonGrp -q -select rebuildSrfVDegree57`;
- int $degreeV;
- switch($degreeBtn123) {
- case 1: $degreeV = 1; break;
- case 2: $degreeV = 2; break;
- case 3: $degreeV = 3; break;
- default:
- switch($degreeBtn57) {
- case 1: $degreeV = 5; break;
- case 2: $degreeV = 7; break;
- case 3: $degreeV = 0; break;
- default: $degreeV = 3; break;
- }
- break;
- }
-
- int $endKnots = `radioButtonGrp -q -select endKnotsRadioButtonGrp` - 1;
- int $keepRange = `radioButtonGrp -q -select keepRangeRadioButtonGrp` - 1;
- int $direction = `radioButtonGrp -q -select directionRadioButtonGrp` - 1;
- int $keepCornerPts = `checkBoxGrp -q -v1 keepCheckBoxGrp`;
- int $keepControlPoints = `checkBoxGrp -q -v2 keepCheckBoxGrp`;
- int $keepNumSpans = `checkBoxGrp -q -v3 keepCheckBoxGrp`;
- int $useGlobalTol = 2 - `radioButtonGrp -q -select toleranceRadioButtonGrp`;
- float $localtol = `floatSliderGrp -q -value localTolFloatFieldGrp`;
- int $keepOrig = `checkBoxGrp -q -v1 keepOriginalCheckBox`;
- int $polygons = `radioButtonGrp -q -select outputPolyRadioButtonGrp` - 1;
-
- optionVar -intValue rebuildSurfaceType ($rebuildType-1);
- optionVar -intValue rebuildSurfaceTypeUniformNumSpansU $numSpansU;
- optionVar -intValue rebuildSurfaceTypeUniformNumSpansV $numSpansV;
- optionVar -intValue rebuildSurfaceTypeUniformDegreeU $degreeU;
- optionVar -intValue rebuildSurfaceTypeUniformDegreeV $degreeV;
- optionVar -intValue rebuildSurfaceEndKnots $endKnots;
- optionVar -intValue rebuildSurfaceKeepRange $keepRange;
- optionVar -intValue rebuildSurfaceDirection $direction;
- optionVar -intValue rebuildSurfaceKeepControlPoints $keepControlPoints;
- optionVar -intValue rebuildSurfaceKeepCornerPoints $keepCornerPts;
- optionVar -intValue rebuildSurfaceKeepNumSpans $keepNumSpans;
- optionVar -intValue rebuildSurfaceUseGlobalTolerance $useGlobalTol;
- optionVar -floatValue rebuildSurfaceLocalTolerance $localtol;
- optionVar -intValue rebuildSurfaceKeepOriginal $keepOrig;
- optionVar -intValue rebuildSurfacePolys $polygons;
-
- nurbsToPolyCallback( $parent, 0 );
- nurbsToSubdivCallback( $parent, 0 );
-
- if( 1 == $doIt ) {
- performRebuildSurface( 0, $goToTool );
- string $tmpCmd = "performRebuildSurface( 0, \"" + $goToTool + "\")";
- addToRecentCommandQueue $tmpCmd "Rebuild Surfaces";
- }
- else if( $doIt ) {
- setToolTo $goToTool;
- }
- }
-
- //
- // Procedure Name:
- // rebuildSurfaceOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
-
- proc rebuildSurfaceOptions( int $inTheTool, string $goToTool )
- {
- // Name of the command for this option box.
- //
- string $commandName = "rebuildSurface";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- global string $gOptionBoxActionToolItem;
- $gOptionBoxActionToolItem = "modelWithToolRebuildSurface";
- global string $gOptionBoxActionToolItemCB;
- $gOptionBoxActionToolItemCB = "rebuildSurfaceToolScript 3";
-
- // Step 1: Get the option box.
- // ============================
- string $layout = getOptionBox();
- setParent $layout;
-
- // Step 2: Pass the command name to the option box.
- // =================================================
- setOptionBoxCommandName($commandName);
-
- // Step 3: Activate the default UI template.
- // ==========================================
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Step 4: Create option box contents.
- // ===================================
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -scr true -tv false;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- radioButtonGrp
- -numberOfRadioButtons 2
- -label "Rebuild Type"
- -label1 "Uniform"
- -label2 "Reduce"
- rebuildTypeRadioGroup1;
-
- radioButtonGrp -shareCollection rebuildTypeRadioGroup1
- -numberOfRadioButtons 2
- -label ""
- -label1 "Match Knots"
- -label2 "No Multiple Knots"
- rebuildTypeRadioGroup2;
-
- radioButtonGrp -shareCollection rebuildTypeRadioGroup1
- -numberOfRadioButtons 2
- -label ""
- -label1 "Non-Rational"
- -label2 "End Conditions"
- rebuildTypeRadioGroup3;
-
- int $hasTrimConvert = `licenseCheck -m edit -typ model`;
- if( $hasTrimConvert ) {
- radioButtonGrp -shareCollection rebuildTypeRadioGroup1
- -numberOfRadioButtons 2
- -label ""
- -label1 "Trim Convert"
- -label2 "Bezier"
- rebuildTypeRadioGroup4;
- }
- else {
- radioButtonGrp -shareCollection rebuildTypeRadioGroup1
- -numberOfRadioButtons 1
- -label ""
- -label1 "Bezier"
- rebuildTypeRadioGroup4;
- }
-
- separator;
-
- // tab for end conditions
- frameLayout -bv false -bs "in" -lv false endKnotsLayout;
- columnLayout endKnotsGroups;
- radioButtonGrp
- -numberOfRadioButtons 2
- -label "End conditions"
- -label1 "No Multiple knots"
- -label2 "Multiple knots"
- endKnotsRadioButtonGrp;
- setParent ..;
- setParent ..;
-
- radioButtonGrp -nrb 3 -l "Parameter Range"
- -l1 "0 to 1"
- -l2 "Keep"
- -l3 "0 to #Spans"
- keepRangeRadioButtonGrp;
-
- radioButtonGrp -nrb 3 -label "Direction"
- -label1 "U" -label2 "V" -label3 "U and V" directionRadioButtonGrp;
-
- checkBoxGrp -ncb 3 -l "Keep"
- -l1 "Corners"
- -l2 "CVs"
- -l3 "NumSpans"
- -on2 ("rebuildSurfaceVisibility " + $parent + " -1 -1 1 -1")
- -of2 ("rebuildSurfaceVisibility " + $parent + " -1 -1 0 -1")
- -on3 ("rebuildSurfaceVisibility " + $parent + " -1 -1 -1 1")
- -of3 ("rebuildSurfaceVisibility " + $parent + " -1 -1 -1 0")
- keepCheckBoxGrp;
-
- frameLayout -bv false -bs "in" -lv false uniformTypeLayout;
- columnLayout uniformTypeSliders;
- intSliderGrp -label "Number of Spans U"
- -min 0 -max 100 -fmx 500 -field on numSpansUIntSliderGrp;
- intSliderGrp -label "Number of Spans V"
- -min 0 -max 100 -fmx 500 -field on numSpansVIntSliderGrp;
-
- radioButtonGrp -label "Degree U"
- -numberOfRadioButtons 3
- -l1 "1 Linear"
- -l2 "2" // Quadratic
- -l3 "3 Cubic"
- -select 3
- rebuildSrfUDegree123;
- radioButtonGrp -shareCollection rebuildSrfUDegree123
- -numberOfRadioButtons 3
- -l1 "5" // Quintic
- -l2 "7"
- -l3 "Original"
- rebuildSrfUDegree57;
-
- radioButtonGrp -label "Degree V"
- -numberOfRadioButtons 3
- -l1 "1 Linear"
- -l2 "2" // Quadratic
- -l3 "3 Cubic"
- -select 3
- rebuildSrfVDegree123;
- radioButtonGrp -shareCollection rebuildSrfVDegree123
- -numberOfRadioButtons 3
- -l1 "5" // Quintic
- -l2 "7"
- -l3 "Original"
- rebuildSrfVDegree57;
-
- setParent ..;
- setParent ..;
-
- separator;
- checkBoxGrp -ncb 1 -l1 "Keep Original" keepOriginalCheckBox;
-
- frameLayout -bv false -bs "in" -lv false toleranceLayout;
- columnLayout toleranceGroups;
- radioButtonGrp
- -numberOfRadioButtons 2
- -label "Use Tolerance"
- -label1 "Global"
- -label2 "Local"
- toleranceRadioButtonGrp;
-
- tabLayout -tabsVisible false localToleranceTabLayout;
- columnLayout globalToleranceNoSlider;
- setParent ..;
- columnLayout localToleranceSlider;
- floatSliderGrp -label "Positional Tolerance"
- -min 0.001 -max 1.0 -fmn 0.00001 -fmx 1000.0
- localTolFloatFieldGrp;
- setParent ..;
- setParent ..;
- setParent ..;
- setParent ..;
-
- // Set the tolerance radio button up so that when "Global" is
- // selected, then the local tolerance slider is disabled.
- // When "Local" is selected then the local tolerance slider is enabled.
- //
- radioButtonGrp -e
- -cc1 ("rebuildSurfaceVisibility " + $parent + " 1 -1 -1 -1")
- -cc2 ("rebuildSurfaceVisibility " + $parent + " 0 -1 -1 -1")
- toleranceRadioButtonGrp;
-
- // Set the layout that contains the number of spans slider and
- // the degree slider so that only displays stuff when the type is Uniform.
- //
- radioButtonGrp -e
- -cc1 ("rebuildSurfaceVisibility " + $parent + " -1 1 -1 -1")
- -cc2 ("rebuildSurfaceVisibility " + $parent + " -1 2 -1 -1")
- rebuildTypeRadioGroup1;
- radioButtonGrp -e
- -cc1 ("rebuildSurfaceVisibility " + $parent + " -1 3 -1 -1")
- -cc2 ("rebuildSurfaceVisibility " + $parent + " -1 4 -1 -1")
- rebuildTypeRadioGroup2;
- radioButtonGrp -e
- -cc1 ("rebuildSurfaceVisibility " + $parent + " -1 5 -1 -1")
- -cc2 ("rebuildSurfaceVisibility " + $parent + " -1 6 -1 -1")
- rebuildTypeRadioGroup3;
-
- if( $hasTrimConvert ) {
- radioButtonGrp -e
- -cc1 ("rebuildSurfaceVisibility " + $parent + " -1 7 -1 -1")
- -cc2 ("rebuildSurfaceVisibility " + $parent + " -1 8 -1 -1")
- rebuildTypeRadioGroup4;
- }
- else {
- radioButtonGrp -e
- -cc1 ("rebuildSurfaceVisibility " + $parent + " -1 8 -1 -1")
- rebuildTypeRadioGroup4;
- }
-
- if( `isTrue "SubdivUIExists"` ) {
- radioButtonGrp -numberOfRadioButtons 3
- -label "Output Geometry"
- -label1 "Nurbs"
- -label2 "Polygons"
- -label3 "Subdiv"
- -cc1 ("frameLayout -e -cl false geomOptionLN; " +
- "frameLayout -e -cl true geomOptionLP; " +
- "frameLayout -e -cl true geomOptionLS;")
- -cc2 ("frameLayout -e -cl true geomOptionLN; " +
- "frameLayout -e -cl false geomOptionLP; " +
- "frameLayout -e -cl true geomOptionLS;")
- -cc3 ("frameLayout -e -cl true geomOptionLN; " +
- "frameLayout -e -cl true geomOptionLP; " +
- "frameLayout -e -cl false geomOptionLS;")
- outputPolyRadioButtonGrp;
- }
- else {
- radioButtonGrp -numberOfRadioButtons 2
- -label "Output Geometry"
- -label1 "Nurbs"
- -label2 "Polygons"
- -cc1 ("frameLayout -e -cl false geomOptionLN; " +
- "frameLayout -e -cl true geomOptionLP; " +
- "frameLayout -e -cl true geomOptionLS;")
- -cc2 ("frameLayout -e -cl true geomOptionLN; " +
- "frameLayout -e -cl false geomOptionLP; " +
- "frameLayout -e -cl true geomOptionLS;")
- outputPolyRadioButtonGrp;
- }
-
- string $par;
- frameLayout -bv false -bs "in" -lv false geomOptionLP;
- $par = `columnLayout geomOptionP`;
- nurbsToPolyAddOptions $par;
- setParent ..;
- setParent ..;
- frameLayout -bv false -bs "in" -lv false geomOptionLN;
- columnLayout geomOptionN;
- setParent ..;
- setParent ..;
- frameLayout -bv false -bs "in" -lv false geomOptionLS;
- $par = `columnLayout geomOptionS`;
- nurbsToSubdivAddOptions $par;
- setParent ..;
- setParent ..;
-
- if( $inTheTool ) {
- separator;
- checkBoxGrp -ncb 2 -l "Tool Behavior"
- -l1 "Exit on Completion"
- -v1 off
- -on1 ("scriptCtx -e -euc true " + $goToTool)
- -of1 ("scriptCtx -e -euc false " + $goToTool)
-
- -l2 "Auto Completion"
- -v2 on
- -on2 ("scriptCtx -e -lac true " + $goToTool)
- -of2 ("scriptCtx -e -lac false " + $goToTool)
- scriptToolExtraWidget;
- }
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- setUITemplate -popTemplate;
-
- // Step 6: Customize the buttons.
- // ==============================
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- if( $inTheTool ) {
- button -edit -l "Rebuild Tool"
- -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
- $applyBtn;
- }
- else {
- button -edit -l "Rebuild"
- -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
- $applyBtn;
- }
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -e
- -command ($callback + " " + $parent + " 0 \"" +
- $goToTool + "\"; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -e
- -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
- $resetBtn;
-
- // Step 7: Set the option box title.
- // =================================
- //
- if( $inTheTool ) {
- setOptionBoxTitle("Rebuild Surface Tool Options");
- }
- else {
- setOptionBoxTitle("Rebuild Surface Options");
- }
-
- // Step 8: Customize the 'Help' menu item text.
- // ============================================
- //
- setOptionBoxHelpTag( "RebuildSurfaces" );
-
- // Step 9: Set the current values of the option box.
- // =================================================
- //
- eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");
-
- // Step 10: Show the option box.
- // =============================
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // rebuildSurfaceHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
-
- proc string rebuildSurfaceHelp()
- {
- return
- " Command: Rebuild Surface - perform surface rebuild\n" +
- "Selection: surface";
- }
-
- global proc performRebuildSurfacePreset()
- {
- rebuildSurfaceSetOptionVars( false );
-
- int $doHistory = `constructionHistory -q -tgl`;
- int $replaceOriginal = !`optionVar -q rebuildSurfaceKeepOriginal`;
- int $rebuildType = `optionVar -q rebuildSurfaceType`;
- float $globalTol = `optionVar -q positionalTolerance`;
-
- int $srfNumSpansU = `optionVar -q rebuildSurfaceTypeUniformNumSpansU`;
- int $srfNumSpansV = `optionVar -q rebuildSurfaceTypeUniformNumSpansV`;
- int $srfDegreeU = `optionVar -q rebuildSurfaceTypeUniformDegreeU`;
- int $srfDegreeV = `optionVar -q rebuildSurfaceTypeUniformDegreeV`;
- int $keepParmRange = `optionVar -q rebuildSurfaceKeepRange`;
- int $endKnots = `optionVar -q rebuildSurfaceEndKnots`;
- int $direction = `optionVar -q rebuildSurfaceDirection`;
- int $keepControlPoints = `optionVar -q rebuildSurfaceKeepControlPoints`;
- int $keepCornerPts = `optionVar -q rebuildSurfaceKeepCornerPoints`;
- int $keepNumSpans = `optionVar -q rebuildSurfaceKeepNumSpans`;
- int $srfUseGlobalTol = `optionVar -q rebuildSurfaceUseGlobalTolerance`;
- float $srfLocalTol = `optionVar -q rebuildSurfaceLocalTolerance`;
- int $polys = `optionVar -q rebuildSurfacePolys`;
-
- if( $keepNumSpans ) {
- $srfNumSpansU = 0;
- $srfNumSpansV = 0;
- }
-
- performRebuildSurfaceSet( $doHistory, $replaceOriginal,
- $rebuildType, $globalTol,
- $srfNumSpansU, $srfNumSpansV,
- $srfDegreeU, $srfDegreeV,
- $endKnots,
- $keepParmRange, $keepCornerPts,
- $keepControlPoints, $direction,
- $srfUseGlobalTol, $srfLocalTol,
- $polys );
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc string assembleCmd()
- {
- string $cmd = "performRebuildSurfaceSet";
-
- setOptionVars(false);
-
- int $doHistory = `constructionHistory -q -tgl`;
- int $replaceOriginal = !`optionVar -q rebuildSurfaceKeepOriginal`;
- int $rebuildType = `optionVar -q rebuildSurfaceType`;
- float $globalTol = `optionVar -q positionalTolerance`;;
-
- int $srfNumSpansU = `optionVar -q rebuildSurfaceTypeUniformNumSpansU`;
- int $srfNumSpansV = `optionVar -q rebuildSurfaceTypeUniformNumSpansV`;
- int $srfDegreeU = `optionVar -q rebuildSurfaceTypeUniformDegreeU`;
- int $srfDegreeV = `optionVar -q rebuildSurfaceTypeUniformDegreeV`;
- int $keepParmRange = `optionVar -q rebuildSurfaceKeepRange`;
- int $endKnots = `optionVar -q rebuildSurfaceEndKnots`;
- int $direction = `optionVar -q rebuildSurfaceDirection`;
- int $keepControlPoints = `optionVar -q rebuildSurfaceKeepControlPoints`;
- int $keepCornerPts = `optionVar -q rebuildSurfaceKeepCornerPoints`;
- int $keepNumSpans = `optionVar -q rebuildSurfaceKeepNumSpans`;
- int $srfUseGlobalTol = `optionVar -q rebuildSurfaceUseGlobalTolerance`;
- float $srfLocalTol = `optionVar -q rebuildSurfaceLocalTolerance`;
- int $polys = `optionVar -q rebuildSurfacePolys`;
-
- if( $keepNumSpans ) {
- $srfNumSpansU = 0;
- $srfNumSpansV = 0;
- }
-
- $cmd = ( $cmd + " " +
- $doHistory + " " +
- $replaceOriginal + " " +
- $rebuildType + " " +
- $globalTol + " " +
- $srfNumSpansU + " " +
- $srfNumSpansV + " " +
- $srfDegreeU + " " +
- $srfDegreeV + " " +
- $endKnots + " " +
- $keepParmRange + " " +
- $keepCornerPts + " " +
- $keepControlPoints + " " +
- $direction + " " +
- $srfUseGlobalTol + " " +
- $srfLocalTol + " " +
- $polys );
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performRebuildSurface
- //
- // Description:
- // Perform the rebuildSurface command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the rebuildSurface command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- //
- // Return Value:
- // None.
- //
-
- global proc string performRebuildSurface(int $action, string $goToTool)
- {
- int $inTheTool = false;
- if( 3 == $action ) {
- $action = 1;
- $inTheTool = true;
- }
-
- string $cmd = "";
- switch ($action) {
-
- case 0:
- setOptionVars(false);
- $cmd = `assembleCmd`;
- eval($cmd);
- break;
-
- case 1:
- rebuildSurfaceOptions( $inTheTool, $goToTool );
- break;
-
- case 2:
- default:
- setOptionVars (false);
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-
-